package org.lex.ftp.util;

import java.awt.Font;
import java.nio.charset.Charset;

import org.lex.app.prefs.ResourceMap;
import org.lex.utils.SystemProperties;


public class DefaultConfiguration {
	static Font DEFAULT_FONT = new Font(Font.DIALOG, Font.PLAIN, 12);

	private DefaultConfiguration() {
	}

	public static void loadDefaultConfiguration(ResourceMap c) {
		DefaultConfiguration.loadDefaultFileExistRules(c);
		c.putProperty(CK.DOWNLOAD_PATH, SystemProperties.userHome());
		// ===========================================================
		c.putProperty(CK.CONNECT_TIMEOUT, "60000");
		c.putProperty(CK.CONNECT_RETRY_ENABLED, "true");
		c.putProperty(CK.CONNECT_RETRY_DELAY, "18000");
		c.putProperty(CK.CONNECT_RETRY_COUNT, "9999");
		c.putString(CK.SERVER_CHARSET, Charset.defaultCharset().name());
		// ===================================================================
		c.putProperty(CK.KEEP_ALIVE_ENABLED, "true");
		c.putProperty(CK.KEEP_ALIVE_COMMAND, "noop");
		c.putProperty(CK.KEEP_ALIVE_DELAY, "20000");
		// ============================================================
		c.putProperty(CK.TRANSFER_MODE, "auto");
		c.putProperty(CK.ASCIIFiles, "c,cpp,cs,h,hpp,java,txt,log");
		// =============================================================
		c.putProperty(CK.SOUND_ENABLED, "true");
		c.putProperty(CK.SOUND_CONNECT, "/lex/ftp/resources/sound/connect.wav");
		c.putProperty(CK.SOUND_DISCONNECT, "/lex/ftp/resources/sound/notify.wav");
		c.putProperty(CK.SOUND_COMPLETE, "/lex/ftp/resources/sound/complete.wav");
		c.putProperty(CK.SOUND_ERROR, "/lex/ftp/resources/sound/error.wav");
	}

	public static void loadDefaultFileExistRules(ResourceMap c) {
		StringBuilder buf = new StringBuilder();
		String def = FileExistRule.DEFAULT.getDisplayName();
		for (int i = 0; i < 8; i++)
			buf.append(def).append(',');
		buf.append(def);
		c.putProperty(CK.EXIST_RULES, buf.toString());
	}
}
